Repository navigation
fix(responses): remap round-2 message lifecycle so codex stops dropping text deltas - #215
Merged
Merged
Conversation
Contributor
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-215Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr215.tgz
npm install -g packageThis comment is automatically updated on each push. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (issue #212)
After a compression, codex logs a flood of
ERROR codex_core::util: OutputTextDelta without active itemand the turn aborts.Root cause
Codex uses the Responses API in wire (function-calling) mode. When the proxy executes a compress/acp_status tool it re-requests upstream (round 2+). In round ≥ 2 the responses adapter suppresses
response.output_item.added/response.content_part.addedfor message items (firstRoundOnly: true) but still forwards rawresponse.output_text.deltaevents carrying the new upstreamitem_ids (core.ts forwardsev.rawunconditionally in wire mode). Codex never saw theoutput_item.addedfor those ids → every delta is dropped with the error above.Introduced in v0.1.37 by 4deb563 (anthropic round-2 framing fix removed the
round === 1guard on raw forwarding; the anthropic adapter got matching lifecycle forwarding, the responses adapter did not). Affected: v0.1.37 – v0.1.47 (latest). v0.1.36 is fine.Fix
Mirror the anthropic adapter's approach for round ≥ 2 in wire mode:
output_item.added(message) in round ≥ 2 is forwarded with a remapped proxy id and client-side output_index, and the full lifecycle (content_part.added,output_text.delta,output_text.done,content_part.done,output_item.done) is rewritten to the same id/index — real-time streaming preserved, SSE sequence coherent.addedno longer forward raw; they fall back to the synthesizedemitTextlifecycle (protocol-safe).Test
New regression test
tests/responses-round2-lifecycle.test.ts(fails on master:orphan deltas: ["msg_2","msg_2"], passes with the fix): asserts every forwardedoutput_text.delta.item_idwas introduced by a forwardedoutput_item.added, the round-2 item streams natively with remapped id, content order is preserved, and the item is closed withoutput_item.done.Full suite: 532/532 pass, typecheck + build clean.